package model;
import static org.junit.Assert.*;

import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;

import org.junit.Test;

//Spring 2012 TCSS360 Deliverable 3 Check-in 1
//Otis Alexander

/**
 * A test class for the auction class.
 */

public class AuctionTest {

	Auction auction = new Auction("test_npo", null, new Date(System.currentTimeMillis()), 0, 0, 0, null, 1);

	@Test
	public void testThatAuctionIDIsInProperFormat() {
		Date d = new Date(System.currentTimeMillis());
		Calendar c = new GregorianCalendar();
		c.setTime(d);
		assertEquals("test_npo" + "-" + c.getDisplayName(Calendar.MONTH, 2, Locale.ENGLISH) + "-"
				+ c.get(Calendar.DAY_OF_MONTH) + "-" + c.get(Calendar.YEAR), auction.getName());
	}

	@Test
	public void testThatItemIdIsAutoGenerated() {
		for (int i = 0; i < 10; i++) {
			auction.addItem("item" + String.valueOf(i),
					1, new BigDecimal(1.00), Integer.toString(1), "nice item");
			assertEquals(i + 1, auction.getItem(i + 1)
					.getID());
		}
	}
}